package com.sky.mapper;

import com.sky.entity.SetmealDish;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * 套餐菜品中间表
 */
@Mapper
public interface SetmealDishMapper {
    /**
     * 根据id查询起售中的套餐数量
     * @param ids
     * @return
     */
    int getSetmealsOnSale(List<Long> ids);

    /**
     * 批量插入套餐菜品中间表
     * @param setmealDishList
     */
    void inertBatchSetmealDish(List<SetmealDish> setmealDishList);

    /**
     * 根据套餐id删除中间表
     * @param setmealId
     */
    @Delete("delete from sky_take_out.setmeal_dish where setmeal_id = #{setmealId}")
    void deleteSetmealDishBySetmealId(Long setmealId);

    /**
     * 根据套餐id查询中间表
     * @param setmealId
     * @return
     */
    @Select("select * from sky_take_out.setmeal_dish where setmeal_id = #{setmealId}")
    List<SetmealDish> getSetmealDishById(Long setmealId);

}
